import {
  q as n,
  p as M,
  ap as T,
  X as w,
  f as A,
  H as R,
  av as C,
  aw as _,
  k as r,
  l as u,
  m as f,
  az as H,
  as as o,
  at as x,
  ay as q
} from "./index-b50e6ef9.js";
import { h as P, b as S } from "./health-43e84a7c.js";
function X(i) {
  return (
    typeof i == "function" ||
    (Object.prototype.toString.call(i) === "[object Object]" && !q(i))
  );
}
function E(i) {
  const h = n([]),
    l = n(!0);
  n({}), M();
  const g = n(1),
    m = n(10),
    v = n(),
    W = n(),
    B = T("reload"),
    y = w({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    I = w({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    J = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      {
        label: "题目",
        prop: "title",
        minWidth: 150,
        formatter: ({ title: e, english: t }) =>
          r("div", null, [
            r("div", null, [e]),
            r(
              u("el-tag"),
              { class: "mx-1", type: "success", effect: "light" },
              X(t) ? t : { default: () => [t] }
            )
          ])
      },
      { label: "单位", prop: "unit", minWidth: 150 },
      {
        label: "类型",
        prop: "type",
        minWidth: 100,
        formatter: ({ type: e }) => {
          if (e == 1) return "简答题";
          if (e == 2) return "单选题";
          if (e == 3) return "多选题";
        }
      },
      {
        label: "单选答案",
        prop: "single",
        minWidth: 150,
        formatter: ({ single: e }) => e || "------"
      },
      {
        label: "多选答案",
        prop: "many",
        minWidth: 150,
        formatter: ({ many: e }) => e || "------"
      },
      { label: "排序", prop: "order", minWidth: 50 },
      {
        label: "是否对比",
        prop: "compare",
        minWidth: 50,
        formatter: ({ compare: e }) =>
          e == 1
            ? r(
                u("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [f("是")] }
              )
            : r(
                u("el-tag"),
                { class: "mx-1", type: "danger", effect: "light" },
                { default: () => [f("否")] }
              )
      },
      {
        label: "必填",
        prop: "is_null",
        minWidth: 50,
        formatter: ({ is_null: e }) =>
          e == 1
            ? r(
                u("el-tag"),
                { class: "mx-1", type: "success", effect: "light" },
                { default: () => [f("是")] }
              )
            : r(
                u("el-tag"),
                { class: "mx-1", type: "danger", effect: "light" },
                { default: () => [f("否")] }
              )
      },
      { label: "创建时间", prop: "create_time", minWidth: 150 },
      { label: "操作", fixed: "right", width: 200, slot: "operation" }
    ],
    V = A(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function k(e) {
    H(e);
  }
  async function z(e) {
    const t = { id: e.id },
      c = JSON.stringify(t),
      b = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(c)) },
      s = await P(b);
    s.code == 200
      ? (x("删除成功", { type: "success" }), B())
      : x(s.msg, { type: "error" });
  }
  function N() {}
  function U(e) {
    (m.value = e), d(void 0, e);
  }
  function L(e) {
    (g.value = e), d(e, void 0);
  }
  function O(e) {}
  function j(e) {
    (I.text = `正在加载第${e}页...`),
      (l.value = !0),
      C(600).then(() => {
        l.value = !1;
      });
  }
  async function D(e, t) {
    (l.value = !0), (v.value = e), (W.value = t);
    const c = { page: g.value, pagesize: m.value, type: v.value, compare: t },
      p = JSON.stringify(c),
      s = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(p)) },
      { data: a } = await S(s);
    (h.value = a.data),
      (y.total = a.total),
      setTimeout(() => {
        l.value = !1;
      }, 500);
  }
  async function d(e = g.value, t = m.value) {
    const c = { page: e, pagesize: t, type: v.value, compare: W.value },
      p = JSON.stringify(c),
      s = { value: o.enc.Base64.stringify(o.enc.Utf8.parse(p)) },
      a = await S(s);
    a.code === 200
      ? ((h.value = a.data.data),
        (y.total = a.data.total),
        setTimeout(() => {
          l.value = !1;
        }, 500))
      : x(a.msg, { type: "error" });
  }
  const F = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    R(() => {
      C().then(() => {
        const { setWatermark: e } = _(i.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        d();
    }),
    {
      loading: l,
      columns: J,
      dataList: h,
      pagination: y,
      buttonClass: V,
      handleList: d,
      onSearch: D,
      resetForm: F,
      handleaddUser: N,
      handleUpdate: k,
      handleDelete: z,
      handleSizeChange: U,
      handleCurrentChange: L,
      handleSelectionChange: O,
      onCurrentChange: j
    }
  );
}
export { E as useRole };
